<?php
class List_product extends Controller{

	function List_product(){
		parent::Controller();
		$this->load->database();
		$this->load->helper('url');
	}
	function index(){
		if($this->session->userdata('username')==''){
			$this->load->view('html/isnotuser');
		}
		else{
			$this->load->view('html/isuser');
		}
		$page_num = '2';
		$this->load->model('list_productmodel');
		$data= $this->list_productmodel->page($page_num,$this->uri->segment(3));
		//print_r($data);exit;
		$total_nums=$data['total_nums'];
		$data['query']=$data[0];
		//print_r($data['query']);exit;
		//foreach($data[1] as $values)
		//foreach($values as $rows)
		//{
		//print_r($values->content);
		//}
		$this->load->library('pagination');
		$config['base_url'] = $this->config->item('base_url').'/index.php/list_product/index/';
		$config['total_rows'] = $total_nums;//总共多少条数据
		$config['per_page'] = $page_num;//每页显示几条数据
		//$config['first_link'] = '第一页';
		//$config['last_link']='最后一页';
		$config['full_tag_open'] = '<p>';
		$config['full_tag_close'] = '</p>';
		$config['first_link'] = '首页';
		$config['first_tag_open'] = '<li>';//“第一页”链接的打开标签。
		$config['first_tag_close'] = '</li>';//“第一页”链接的关闭标签。
		$config['last_link'] = '尾页';//你希望在分页的右边显示“最后一页”链接的名字。
		$config['last_tag_open'] = '<li>';//“最后一页”链接的打开标签。
		$config['last_tag_close'] = '</li>';//“最后一页”链接的关闭标签。
		$config['next_link'] = '下一页';//你希望在分页中显示“下一页”链接的名字。
		$config['next_tag_open'] = '<li>';//“下一页”链接的打开标签。
		$config['next_tag_close'] = '</li>';//“下一页”链接的关闭标签。
		$config['prev_link'] = '上一页';//你希望在分页中显示“上一页”链接的名字。
		$config['prev_tag_open'] = '<li>';//“上一页”链接的打开标签。
		$config['prev_tag_close'] = '</li>';//“上一页”链接的关闭标签。
		$config['cur_tag_open'] = '<li class="current">';//“当前页”链接的打开标签。
		$config['cur_tag_close'] = '</li>';//“当前页”链接的关闭标签。
		$config['num_tag_open'] = '<li>';//“数字”链接的打开标签。
		$config['num_tag_close'] = '</li>';
		$this->pagination->initialize($config);
		//$this->pagination->initialize($config);


		$this->load->view('admin_listproduct',$data);

	}
	function test_list(){
		$this->load->model('addproductmodel');
		$data['query']=$this->addproductmodel->getParentSort();
		$this->load->view('test_listView',$data);
	}

	function list_goods(){
		if($this->session->userdata('username')==''){
			$this->load->view('html/isnotuser');
		}
		else{
			$this->load->view('html/isuser');
		}
		$this->load->model('list_productmodel');
		$data['query']=$this->commonmodel->get('gaoji_product');
$data['phone']=$this->commonmodel->get_where('gaoji_productsort','pid',1);
		$data['dc']=$this->commonmodel->get_where('gaoji_productsort','pid',4);
		$data['notebook']=$this->commonmodel->get_where('gaoji_productsort','pid',19);
		//print_r($data);exit;
		$this->load->view('html/product',$data);
	}


	function goods_content(){
		if($this->session->userdata('username')==''){
			$this->load->view('html/isnotuser');
		}
		else{
			$this->load->view('html/isuser');
		}
		$productid=$this->uri->segment(3);
		//echo $productid;
		$this->load->model('list_productmodel');
		$data['query']=$this->list_productmodel->getContent($productid);
		//print_r($data);exit;
		$this->load->view('html/productcontent',$data);


	}


	function do_upload()
	{
		$config['upload_path'] = './uploads/';
		$config['allowed_types'] = 'gif|jpg|png';
		$config['max_size'] = '100';
		$config['max_width']  = '1024';
		$config['max_height']  = '768';

		$this->load->library('upload', $config);

		if ( ! $this->upload->do_upload())
		{
			$error = array('error' => $this->upload->display_errors());

			//$this->load->view('upload_form', $error);
		}
		else
		{
			$data = array('upload_data' => $this->upload->data());

			//x  $this->load->view('upload_success', $data);
		}
	}

}
?>